//
//  FLLBuyKeyViewController.m
//  FLLGodOfCooking
//
//  Created by LL.F on 16/9/16.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "FLLBuyKeyViewController.h"
#import "FLLBuyKeyTableViewCell.h"
#import "FLLMacro.h"
#import "GetHeightTools.h"

@interface FLLBuyKeyViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *buyKeyTableView;
@end

@implementation FLLBuyKeyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self createBuyKeyTableView];
    
}
- (void)createBuyKeyTableView
{
    
    self.buyKeyTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 115 * kHeightScale) style:UITableViewStylePlain];
    self.buyKeyTableView.delegate = self;
    self.buyKeyTableView.dataSource = self;
    self.buyKeyTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.buyKeyTableView.bounces = NO;
    [self.buyKeyTableView registerNib:[UINib nibWithNibName:@"FLLBuyKeyTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"buyKeyTableCell"];
    [self.view addSubview:_buyKeyTableView];
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    FLLBuyKeyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"buyKeyTableCell"];
    [cell.dishImageView sd_setImageWithURL:[NSURL URLWithString:_dic.pick_image] placeholderImage:[UIImage new] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
    }];
    cell.contentLabel.text = _dic.pick;
    cell.contentLabel.font = [UIFont systemFontOfSize:13 * kWidthScale];
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return SCREEN_WIDTH / 2.0 + [GetHeightTools heightWith:_dic.pick];
}
- (void)setDic:(BuyKeyData *)dic
{

    _dic = dic;
    [self.buyKeyTableView reloadData];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
